// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: rolling_file.hpp 219 2008-09-04 14:50:25Z heavyzheng $
//

#ifndef ZZHENG_LOGGING_ROLLING_FILE_HPP_20080902__
#define ZZHENG_LOGGING_ROLLING_FILE_HPP_20080902__

#include <zzheng/logging/config.hpp>
#include <zzheng/logging/destination.hpp>
#include <zzheng/logging/log_level.hpp>

#include <string>

namespace zzheng {
namespace logging {

    class rolling_file: public destination {

    public:

        explicit rolling_file(): destination(rolling_file_destination) {
            // Do nothing.
        }

        // TODO: copy?
        // Use auto-generated destructor.

        std::string dirname() const {
            return get_prop<std::string>("dirname", std::string());
        }

        rolling_file& set_dirname(const std::string& dirname) {
            set_prop("dirname", dirname);
            return *this;
        }

        std::string basename() const {
            return get_prop<std::string>("basename", std::string());
        }

        rolling_file& set_basename(const std::string& basename) {
            set_prop("basename", basename);
            return *this;
        }

        unsigned int max_file_size_kb() const {
            return get_prop<unsigned int>("max_file_size_kb", 0);
        }

        rolling_file& set_max_file_size_kb(unsigned int max_file_size_kb) {
            set_prop("max_file_size_kb", max_file_size_kb);
            return *this;
        }

        unsigned int max_backup_index() const {
            return get_prop<unsigned int>("max_backup_index");
        }

        rolling_file& set_max_backup_index(unsigned int max_backup_index) {
            set_prop("max_backup_index", max_backup_index);
            return *this;
        }

    }; // class rolling_file

} // namespace zzheng::logging
} // namespace zzheng

#endif // ZZHENG_LOGGING_ROLLING_FILE_HPP_20080902__

